package com.mlk.sign.API;

import com.mlk.constant.OK;
import com.mlk.core.util.ServerResponse;
import com.mlk.engSystem.constant.SystemParam;
import com.mlk.engSystem.service.EngSysParamService;
import com.mlk.sign.service.EngSignService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * 用户签到
 */
@RestController
@RequestMapping("/api/sign")
public class EngSignAPI {

    @Resource
    private EngSignService engSignService;

    @Resource
    private EngSysParamService engSysParamService;

    /**
     * 用户签到
     * @param openId
     * @return
     */
    @GetMapping("sign")
    @OK
    public ServerResponse sign(String openId){
        return this.engSignService.sign(openId);
    }

    /**
     * 获取用户的签到总积分
     * @return
     */
    @GetMapping("getTotalSignScore")
    @OK
    public ServerResponse getTotalSignScore(String openId){
        return this.engSignService.getTotalSignScore(openId);
    }

    /**
     * 获取用户的总签到次数
     * @return
     */
    @GetMapping("getTotalSignDays")
    @OK
    public ServerResponse getTotalSignDays(String openId){
        return this.engSignService.getTotalSignDays(openId);
    }

    /**
     * 获取最近的七天的签到情况
     * @param openId
     * @return
     */
    @GetMapping("lastSevenDaysSignInfo")
    @OK
    public ServerResponse lastSevenDaysSignInfo(String openId){
        return this.engSignService.lastSevenDaysSignInfo(openId);
    }

    /**
     * 用户签到规则
     * @return
     */
    @GetMapping("signGuide")
    public String signGuide(){
        return engSysParamService.getValue(SystemParam.CAN_GET_SCORE_OF_DAYS);
    }
}
